﻿@model CustomerOrderListModel
@{
    Layout = "~/Views/Shared/_ColumnsTwo.cshtml";

    //title
    Html.AddTitleParts(T("PageTitle.Account").Text);
}
@using Nop.Web.Models.Customer;
@section left
{
    @Html.Partial("MyAccountNavigation", Model.NavigationModel, new ViewDataDictionary())
}


<div class="features_items my-account-page"><!--features_items-->
    <h2 class="title text-center">@T("Account.MyAccount") - @T("Account.CustomerOrders")</h2>
    <div class="custom-page-box-div">
        
        @if (Model.RecurringOrders.Count > 0)
            {

                using (Html.BeginForm())
                {

                    



                    <div class="section recurring-payments">
                        <div class="title">
                            <strong>@T("Account.CustomerOrders.RecurringOrders")</strong>
                        </div>
                        <div id="legend">
                            <legend></legend>
                        </div>


                        <div id="cart_items">
    

                            <div class="table-responsive cart_info">
                                <table class="table table-condensed">
                                    <thead>
                                        <tr class="cart_menu">
                                            <td class="a-center start-date">
                                                @T("Account.CustomerOrders.RecurringOrders.StartDate")
                                            </td>
                                            <td class="a-center cycle-info">
                                                @T("Account.CustomerOrders.RecurringOrders.CycleInfo")
                                            </td>
                                            <td class="a-center next-payment">
                                                @T("Account.CustomerOrders.RecurringOrders.NextPayment")
                                            </td>
                                            <td class="a-center total-cycles">
                                                @T("Account.CustomerOrders.RecurringOrders.TotalCycles")
                                            </td>
                                            <td class="a-center cycles-remaining">
                                                @T("Account.CustomerOrders.RecurringOrders.CyclesRemaining")
                                            </td>
                                            <td class="a-center initial-order">
                                                @T("Account.CustomerOrders.RecurringOrders.InitialOrder")
                                            </td>
                                            <td class="a-center cancel">
                                                @T("Account.CustomerOrders.RecurringOrders.Cancel")
                                            </td>

                
                                        </tr>


                                    </thead>
                                    <tbody>
                                        @foreach (var item in Model.RecurringOrders)
                                        {
                                            <tr>
                                            <td class="a-center start-date">
                                                @item.StartDate
                                            </td>
                                            <td class="a-center cycle-info">
                                                @item.CycleInfo
                                            </td>
                                            <td class="a-center next-payment">
                                                @item.NextPayment
                                            </td>
                                            <td class="a-center total-cycles">
                                                @item.TotalCycles
                                            </td>
                                            <td class="a-center cycles-remaining">
                                                @item.CyclesRemaining
                                            </td>
                                            <td class="a-center initial-order">
                                                <a href="@Url.RouteUrl("OrderDetails", new { orderId = item.InitialOrderId })">@string.Format(T("Account.CustomerOrders.RecurringOrders.ViewInitialOrder").Text, item.InitialOrderId)</a>
                                            </td>
                                            <td class="a-center cancel">
                                                @if (item.CanCancel)
                                                {
                                                    <input type="submit" name="cancelRecurringPayment@(item.Id)" value="@T("Account.CustomerOrders.RecurringOrders.Cancel")" class="button-2 cancel-recurring-order-button" />
                                                }
                                            </td>
                                        </tr>         
                                        }
            
                                    </tbody>
                                </table>
                            </div>

                        </div>










                        
                    </div>
                }
                if (Model.CancelRecurringPaymentErrors.Count > 0)
                {
                    <div class="alert alert-danger message-error">
                        
                            @for (int i = 0; i < Model.CancelRecurringPaymentErrors.Count; i++)
                            {
                                <div>@Model.CancelRecurringPaymentErrors[i]</div>
                            }
                        

                    </div>
                }
            }
            <div class="order-list">
                @if (Model.Orders.Count > 0)
                {
                    foreach (var order in Model.Orders)
                    {
                        <div class="section order-item space15px">
                            <div class="title">
                                <strong>@T("Account.CustomerOrders.OrderNumber"): @order.Id</strong>
                            </div>
                            <legend></legend>
                            <ul class="info">
                                <li>
                                    @T("Account.CustomerOrders.OrderStatus"): @order.OrderStatus</li>
                                <li>
                                    @T("Account.CustomerOrders.OrderDate"): @order.CreatedOn.ToString()</li>
                                <li>
                                    @T("Account.CustomerOrders.OrderTotal"): @order.OrderTotal
                                </li>
                            </ul>
                            <div class="buttons">
                                @if (order.IsReturnRequestAllowed)
                                {
                                    <input type="button" value="@T("Account.CustomerOrders.ReturnItems")" class="button-1 btn btn-primary" onclick="setLocation('@Url.RouteUrl("ReturnRequest", new { orderId = order.Id })')" />
                                }
                                <input type="button" value="@T("Account.CustomerOrders.OrderDetails")" class="button-1 btn btn-primary" onclick="setLocation('@Url.RouteUrl("OrderDetails", new { orderId = order.Id })')" />
                            </div>
                        </div>
                    }
                }
                else
                {
                    @T("Account.CustomerOrders.NoOrders")
                }
            </div>
                
    </div>
</div>
